// @Author EthanScriptOn
// @Desc
package starter

import (
	"errors"
	"gitee.com/fatzeng/srf_switch_basic_components/util"
	"gitee.com/fatzeng/srf_switch_log/log"
	"gitee.com/fatzeng/srf_switch_log/log_context"
	protocol_log "gitee.com/fatzeng/srf_switch_protocol/protocol/log"
)

func LogInitialization(ctx *log_context.LogInitializationContext) (err error) {
	defer util.HandleErr(&err)
	if ctx == nil {
		return errors.New("need an LogInitializationContext")
	}
	if err = Start(ctx); err != nil {
		return err
	}
	logger, err := log.Logger()
	if err != nil {
		return err
	}
	protocol_log.SetLogger(logger)
	return
}
